package util;

import com.jfinal.aop.Interceptor;
import com.jfinal.ext.interceptor.excel.ExcelUploadInterceptor;
import com.jfinal.ext.kit.PoiExt;
import com.jfinal.ext.kit.excel.Rule;
import com.jfinal.kit.PathKit;
import com.jfinal.plugin.activerecord.Model;
import com.jfinal.upload.UploadFile;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;

import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import java.io.*;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Map;

/**
 * Created by Administrator on 2015/8/27.
 */
public class DefaultExcelUpload<User> extends ExcelUploadInterceptor implements Interceptor {
    @Override
    public Rule configRule() {
        Rule rule = null;
        String metadata = "<rule>\n" +
                "    <name></name>\n" +
                "    <sheetNo></sheetNo>\n" +
                "    <start>1</start>\n" +
                "    <end>10</end>\n" +
                "    <rowFilter>com.xx.xx</rowFilter>\n" +
                "    <preExcelProcessor>com.xx.yy</preExcelProcessor>\n" +
                "    <postExcelProcessor>com.xx.zz</postExcelProcessor>\n" +
                "    <preListProcessor>com.xx.aa</preListProcessor>\n" +
                "    <postListProcessor>com.xx.bb</postListProcessor>\n" +
                "    <cells>\n" +
                "        <cell>\n" +
                "            <index>1</index>\n" +
                "            <attribute>age</attribute>\n" +
                "            <convert>com.xx.xxx</convert>\n" +
                "            <validate>com.xx.xxxxx</validate>\n" +
                "        </cell>\n" +
                "    </cells>\n" +
                "</rule>";
        try {
            JAXBContext jaxbContext = JAXBContext.newInstance(Rule.class);
            Unmarshaller um = jaxbContext.createUnmarshaller();
            rule = (Rule) um.unmarshal(new ByteArrayInputStream(metadata.getBytes()));
        } catch (JAXBException e) {

        }
        return  rule;
    }

    @Override
    public void callback(Model model) {

    }

    public static void main(String[] args)   {


    }

}
